In this script, there is conducted the estimation for the measure_marginal approach for a single given env. The programs is the set of bytecode programs with varying number of opcodes. The measurements are time measurements of program runs or benchmarks. The estimation of each opcode is calculated as the regression against the number of a given opcode in the executed programs.

Parametrization. The evm client name env=geth, the file with programs programs=pg_marginal_full_step5_v2.csv, the file with measurements results=results_marginal_full_geth.csv,
the output csv file with estimated cost output_estimated_cost=reports-08.11.2024/estimated_cost_geth_full.csv, should the details be included in the report details=FALSE.

The comparision of result. Before and after removing outlying measurement. Switch removed_outliers to FALSE to see the comparison.

if (removed_outliers) {
  measurements = remove_compare_outliers(measurements, 'measure_total_time_ns', c(env))
}

Now we can investigate the linear regressions.

for (opcode in all_opcodes) {
  estimate = compute_all(opcode=opcode, env=env, use_median=TRUE, plots=ifelse(details,'all','scatter'))
  estimates[nrow(estimates) + 1, ] = c(opcode, estimate, env)
}

The resulting estimates based on the regressions above.

estimates
##                 op estimate_marginal_ns estimate_marginal_ns_stderr  env
## 1              ADD           -51.440909                  4.00606261 geth
## 2              MUL            13.004545                  0.99019690 geth
## 3              SUB             5.244545                  2.00360875 geth
## 4              DIV             7.806364                  0.18376508 geth
## 5             SDIV             9.580000                  0.15556290 geth
## 6              MOD             7.410909                  0.24734699 geth
## 7             SMOD             9.315455                  0.14150282 geth
## 8           ADDMOD            12.614545                  0.26053276 geth
## 9           MULMOD            22.426364                  0.27870536 geth
## 10             EXP            26.974545                  0.38723384 geth
## 11      SIGNEXTEND             9.003636                  0.19296726 geth
## 12              LT             7.322727                  0.18791666 geth
## 13              GT             7.390000                  0.20104845 geth
## 14             SLT            10.649091                  1.17873584 geth
## 15             SGT             8.035455                  0.25727237 geth
## 16              EQ             7.010909                  0.24735441 geth
## 17          ISZERO             4.509091                  0.39113454 geth
## 18             AND             7.020909                  0.19982798 geth
## 19              OR             7.009091                  0.18487829 geth
## 20             XOR             6.971818                  0.22909953 geth
## 21             NOT             5.000000                  0.09550023 geth
## 22            BYTE             8.254545                  0.24385939 geth
## 23             SHL             7.913636                  0.38163476 geth
## 24             SHR             8.247273                  0.19265102 geth
## 25             SAR             8.616364                  0.20814366 geth
## 26       KECCAK256           406.541818                  2.66244611 geth
## 27         ADDRESS            20.200000                  0.10600865 geth
## 28          ORIGIN             6.310909                  0.30082775 geth
## 29          CALLER            11.453636                  0.79268111 geth
## 30       CALLVALUE             4.957273                  0.19887447 geth
## 31    CALLDATALOAD            33.499091                  1.47615635 geth
## 32    CALLDATASIZE             5.051818                  0.16246240 geth
## 33    CALLDATACOPY            39.728182                  1.28979675 geth
## 34        CODESIZE             5.305455                  0.17838269 geth
## 35        CODECOPY            26.637273                  1.68601712 geth
## 36        GASPRICE             5.699091                  0.44168670 geth
## 37     EXTCODESIZE            54.402727                  1.49153322 geth
## 38     EXTCODECOPY            75.333636                  3.08528679 geth
## 39  RETURNDATASIZE             4.389091                  0.42311061 geth
## 40  RETURNDATACOPY             6.158182                  4.85793288 geth
## 41     EXTCODEHASH            80.294545                  2.01307307 geth
## 42        COINBASE             7.583636                  0.25341669 geth
## 43       TIMESTAMP             4.667273                  0.49415909 geth
## 44          NUMBER             5.216364                  0.48731155 geth
## 45      DIFFICULTY             7.965455                  0.59710935 geth
## 46        GASLIMIT             5.489091                  0.71887551 geth
## 47         CHAINID             7.873636                  0.73076680 geth
## 48     SELFBALANCE            33.955455                  0.81140284 geth
## 49             POP             6.351818                  0.92773859 geth
## 50           MLOAD            13.090000                  2.58387312 geth
## 51          MSTORE            15.542727                  0.64385853 geth
## 52     MSTORE_COLD            20.066364                  0.79946671 geth
## 53         MSTORE8            15.713636                  1.26344868 geth
## 54            JUMP            13.087273                  1.56076857 geth
## 55           JUMPI            16.255455                  3.06719811 geth
## 56              PC             4.705455                  0.55076072 geth
## 57           MSIZE             4.151818                  0.57301828 geth
## 58             GAS             5.121818                  0.70241640 geth
## 59        JUMPDEST             4.398182                  0.42178030 geth
## 60           MCOPY            21.664545                  1.12249799 geth
## 61      MCOPY_COLD            26.647273                  1.09809820 geth
## 62           PUSH0             3.850000                  0.65833604 geth
## 63            LOG0           213.440909                  8.29884021 geth
## 64            LOG1           235.254545                  5.49659382 geth
## 65            LOG2           254.376364                  5.35003054 geth
## 66            LOG3           267.572727                  3.93156682 geth
## 67            LOG4           278.936364                  4.66722409 geth
## 68          CREATE          7374.918182                 29.02125572 geth
## 69            CALL           492.700909                  7.01310003 geth
## 70          RETURN            24.008182                  8.83634721 geth
## 71    DELEGATECALL           384.894545                  5.37142205 geth
## 72      STATICCALL           436.326364                  6.70211703 geth
## 73          REVERT            63.060000                  3.65110753 geth
## 74           PUSH1             5.988182                  0.15524825 geth
## 75           PUSH2             9.920909                  0.45168504 geth
## 76           PUSH3             9.985455                  0.62710904 geth
## 77           PUSH4             9.948182                  0.50785845 geth
## 78           PUSH5             9.115455                  0.23493175 geth
## 79           PUSH6            10.024545                  0.21998643 geth
## 80           PUSH7            10.144545                  0.18761443 geth
## 81           PUSH8            10.646364                  0.69364020 geth
## 82           PUSH9             9.098182                  0.56940483 geth
## 83          PUSH10            14.731818                  1.07020912 geth
## 84          PUSH11             9.487273                  0.16370481 geth
## 85          PUSH12             8.770000                  0.21612477 geth
## 86          PUSH13            10.134545                  0.24097598 geth
## 87          PUSH14             9.939091                  0.26840532 geth
## 88          PUSH15            10.447273                  0.32586059 geth
## 89          PUSH16             8.818182                  0.50234894 geth
## 90          PUSH17            10.014545                  0.66363941 geth
## 91          PUSH18            10.110909                  0.53693139 geth
## 92          PUSH19            10.787273                  0.21256318 geth
## 93          PUSH20             9.968182                  0.19637088 geth
## 94          PUSH21            10.198182                  0.31579131 geth
## 95          PUSH22            11.531818                  0.30135217 geth
## 96          PUSH23            11.699091                  0.34922175 geth
## 97          PUSH24            10.576364                  0.48727650 geth
## 98          PUSH25             9.968182                  0.27626244 geth
## 99          PUSH26            10.360000                  0.19707783 geth
## 100         PUSH27             9.917273                  0.22150645 geth
## 101         PUSH28            10.272727                  0.32293421 geth
## 102         PUSH29            10.369091                  0.28390301 geth
## 103         PUSH30            10.496364                  0.62398082 geth
## 104         PUSH31            11.196364                  0.20737637 geth
## 105         PUSH32            10.728182                  0.18510638 geth
## 106           DUP1             5.751818                  0.15266563 geth
## 107           DUP2             5.595455                  0.09854544 geth
## 108           DUP3             5.303636                  0.51241914 geth
## 109           DUP4             5.192727                  0.56996738 geth
## 110           DUP5             4.596364                  0.61965096 geth
## 111           DUP6             5.766364                  0.20685475 geth
## 112           DUP7             5.867273                  0.21660711 geth
## 113           DUP8             6.043636                  0.17465590 geth
## 114           DUP9             6.154545                  0.32172914 geth
## 115          DUP10             5.941818                  0.30320964 geth
## 116          DUP11             6.428182                  0.68779328 geth
## 117          DUP12             5.975455                  0.59110416 geth
## 118          DUP13             5.477273                  0.10260832 geth
## 119          DUP14             5.689091                  0.18698615 geth
## 120          DUP15             5.720000                  0.17719786 geth
## 121          DUP16             6.559091                  0.94966405 geth
## 122          SWAP1             6.424545                  0.50522622 geth
## 123          SWAP2             6.217273                  0.12882139 geth
## 124          SWAP3             6.181818                  0.14070529 geth
## 125          SWAP4             7.347273                  0.57817165 geth
## 126          SWAP5             5.833636                  0.15655585 geth
## 127          SWAP6             5.820909                  0.37275080 geth
## 128          SWAP7             6.112727                  0.92554027 geth
## 129          SWAP8             5.881818                  0.58024725 geth
## 130          SWAP9            13.953636                  2.07600748 geth
## 131         SWAP10             4.120909                  0.74979710 geth
## 132         SWAP11             5.113636                  1.07671724 geth
## 133         SWAP12             6.487273                  0.30956351 geth
## 134         SWAP13             7.237273                  0.82556595 geth
## 135         SWAP14             5.831818                  0.52400546 geth
## 136         SWAP15             6.023636                  0.11961984 geth
## 137         SWAP16             6.059091                  0.12227376 geth

The results are exported to reports-08.11.2024/estimated_cost_geth_full.csv.